//
//  WYNotificationTooler.m
//  Boss
//
//  Created by admin on 2018/8/28.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYNotificationTooler.h"
#import "WYRedPacketMessageController.h"
#import "WYCommentMeController.h"
#import "WYLoginController.h"
#import "WYBaseNavigationController.h"
#import "WYPusherModel.h"
#import "WYForwardMeController.h"
#import "WYCommentMeController.h"
#import "WYFollowMeController.h"
#import "WYMessageDetailController.h"
@implementation WYNotificationTooler
static WYNotificationTooler *_shareInstance=nil;
+ (WYNotificationTooler *) sharedInstance
{
    if(!_shareInstance)
    {
        _shareInstance=[[WYNotificationTooler alloc] init];
    }
    return _shareInstance;
}


+(void)pushToStateWithJson:(id)Json
{
    if (![_shareInstance isLogin]) {
        return;
    }
    
    WYPusherModel *model = [WYPusherModel getPusherModelFromJson:Json];
    
    if ([model.type isEqualToString:@"forward"]) {
        WYForwardMeController *fmvc = [[WYForwardMeController alloc]init];
        [[UIApplication sharedApplication].keyWindow.rootViewController.navigationController pushViewController:fmvc animated:YES];
    }
    
    if ([model.type isEqualToString:@"comment"]) {
        WYCommentMeController *cmc = [[WYCommentMeController alloc]init];
        [[UIApplication sharedApplication].keyWindow.rootViewController.navigationController pushViewController:cmc animated:YES];
    }
    
    if ([model.type isEqualToString:@"reply"]) {
        WYCommentMeController *cmc = [[WYCommentMeController alloc]init];
        [[UIApplication sharedApplication].keyWindow.rootViewController.navigationController pushViewController:cmc animated:YES];
    }
    
    if ([model.type isEqualToString:@"follow"]) {
        WYFollowMeController *cmc = [[WYFollowMeController alloc]init];
        [[UIApplication sharedApplication].keyWindow.rootViewController.navigationController pushViewController:cmc animated:YES];
    }
    
    if ([model.type isEqualToString:@"sys"]) {
        WYMessageDetailController *cmc = [[WYMessageDetailController alloc]init];
        cmc.msgID = model.msgId;        
        [[UIApplication sharedApplication].keyWindow.rootViewController.navigationController pushViewController:cmc animated:YES];
    }
    
    
    
    
    
    
    
}

-(BOOL)isLogin
{
    NSString *token =[WYStoreModule currentToken];
    if (token.length) {
        return YES;
    }else{
        WYLoginController *loginVc = [[WYLoginController alloc] initWithNibName:@"WYLoginController" bundle:nil];
        WYBaseNavigationController *nav = [[WYBaseNavigationController alloc]initWithRootViewController:loginVc];
        [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:nav animated:YES completion:nil];
        return NO;
    }
}



@end
